﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace DataFileApplication_WPF.Extensions
{
    public class TreeItemRenameConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            //treeview重命名时切换控件，实现可修改状态
            //判断是否是Rename状态，为True状态下textbox显示，textBlock不显示
            if ((bool)value == true && parameter.ToString() == "txb")
            {
                return Visibility.Visible;
            }
            else if ((bool)value == false && parameter.ToString() == "txb")
            {
                return Visibility.Collapsed;
            }
            else if ((bool)value == true && parameter.ToString() == "txbk")
            {
                return Visibility.Collapsed;
            }
            else if ((bool)value == false && parameter.ToString() == "txbk")
            {
                return Visibility.Visible;
            }
            else
            {
                return null;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
